import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询商品列表
export function listGoods(data) {
  return request({
    url: '/market/goods/goodsList',
    method: 'post',
    data: data
  })
}

// 查询商品详细
export function getGoods(goodsId) {
  return request({
    url: '/market/goods/' + parseStrEmpty(goodsId),
    method: 'get'
  })
}

// 新增商品
export function addGoods(data) {
  return request({
    url: '/market/goods',
    method: 'post',
    data: data
  })
}

// 修改商品
export function updateGoods(data) {
  return request({
    url: '/market/goods',
    method: 'put',
    data: data
  })
}

// 删除商品
export function delGoods(goodsId) {
  return request({
    url: '/market/goods/' + goodsId,
    method: 'delete'
  })
}

// 商品状态修改
export function changeGoodsStatus(goodsId, status) {
  const data = {
    goodsId,
    status
  }
  return request({
    url: '/market/goods/goodsChangeStatus',
    method: 'put',
    data: data
  })
}
